/**
 * 
 */
package co.fitstart.mobile.dao.support;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.demo2do.core.persistence.GenericDaoSupport;

import co.fitstart.entity.credit.order.CreditOrder;
import co.fitstart.entity.user.User;

/**
 * @author Guangli Yan
 *
 */
@Repository
public class CreditOrderDaoSupport {

	@Autowired
	private GenericDaoSupport genericDaoSupport;
	
	/**
	 * @param user
	 * @param beginIndex
	 * @param maxResult
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<CreditOrder> list(User user, int beginIndex, int maxResult) {
		
		String sentence = "FROM CreditOrder WHERE disabled = false AND user = :user ORDER BY createTime DESC ";
		
		Map<String , Object> parameters = new HashMap<>();
		
		parameters.put("user", user);
		
		List<CreditOrder> list = genericDaoSupport.searchForList(sentence, parameters, beginIndex, maxResult);
		
		return list;
	}

}
